using GearUp.Crawler.Entities;
using Xunit;
using Xunit.Extensions;

namespace GearUp.Crawler.Tests
{
    public class WhenALorebookDocumentIsLoded
    {
        private string theUrl = "http://lorebook.lotro.com/wiki/Armour:Breastplate_of_the_Lady%27s_Courage";
        [Fact]
        public void ShouldBeAbleToExtractTheItemDetails()
        {
            var document = new LorebookDocument(Resource1.ArmourPageHtml);
            var itemDetails = document.OfficialLorebookEntry();
            var parser = new LorebookItemParser();
            var item = parser.ParseHtmlNode(itemDetails,theUrl);
            Assert.NotNull(item);
            Assert.Equal(theUrl, item.ItemUrl);
            Assert.Equal("http://content.turbine.com/sites/lorebook.lotro.com/images/icons/item/chest/eq_chest_hvy_tier2_set_1_captain.png", item.ItemIconUrl);
            Assert.Equal("Breastplate of the Lady's Courage",item.Name);
            Assert.Equal(ItemBinding.BindOnAcquire, item.ItemBinding);
            Assert.Equal(true,item.UniqueItem);
            Assert.Equal(170, item.Effects.PowerBonus);
            Assert.Equal(42, item.Effects.MightBonus);
            Assert.Equal(21, item.Effects.AgilityBonus);
            Assert.Equal(42, item.Effects.VitalityBonus);
            Assert.Equal(20, item.Effects.Radiance);
            Assert.Equal(95, item.Durability);
            Assert.Equal("Tough", item.Sturdiness);
            Assert.Equal(60, item.MinimumLevel);
            Assert.Equal(1, item.Classes.Count);
            Assert.True(item.Classes.Contains("Captain"));
            Assert.True(item.Description.StartsWith("This armour is granted"));
            Assert.Equal("Armour of the Lady's Courage", item.SetName);
            Assert.Equal(6, item.SetPieces.Count);
            Assert.Equal(5, item.SetEffects.Count);
        }
    }
}